package com.zmn.oms.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 服务项目类型枚举
 *
 * @author chengguang
 * @date 2022/09/05
 */
@AllArgsConstructor
@Getter
public enum ServItemTypeEnum {

    /**
     * values
     */
    SERVICE_ITEM_TYPE_ORDER(OrderConsts.SERVICE_ITEM_TYPE_ORDER, "服务价格"),
    SERVICE_ITEM_TYPE_FAULT(OrderConsts.SERVICE_ITEM_TYPE_FAULT, "计价器2.0"),
    SERVICE_ITEM_TYPE_ADVANCE_PAY(OrderConsts.SERVICE_ITEM_TYPE_ADVANCE_PAY, "提前付"),
    SERVICE_ITEM_TYPE_QUOTATION_THREE(OrderConsts.SERVICE_ITEM_TYPE_QUOTATION_THREE, "服务项"),
    SERVICE_ITEM_TYPE_FINAL_PRICE(OrderConsts.SERVICE_ITEM_TYPE_FINAL_PRICE, "一口价"),
    ;

    private final Integer code;
    private final String name;


    public static String getServItemTypeName(Integer code) {
        Optional<ServItemTypeEnum> first = Arrays.stream(ServItemTypeEnum.values()).filter(servItemTypeEnum ->
                Objects.equals(code, servItemTypeEnum.getCode())).findFirst();
        if (!first.isPresent()){
            return "未知";
        }
        return first.get().getName();
    }
}
